﻿
using System ;
using System.Windows.Forms ;

using MskEdit.Dxf.Model ;


namespace MskEdit.Dxf.Frontend
{

    public class DxfEntitiesTreeNode : TreeNode 
    {
        private DxfEntities dxfEntities_ ;
        
        
        public static DxfEntitiesTreeNode TryFrom( DxfEntities dxfEntities, DxfEntitiesTreeNode fallbackValue ) {
        
            if ( dxfEntities == null )
                return fallbackValue ;
                
            return new DxfEntitiesTreeNode( dxfEntities ) ;
        }
        
        
        public DxfEntitiesTreeNode( DxfEntities dxfEntities ) {
        
            dxfEntities_ = dxfEntities ;
            this.Text = "Entities " ;
                
            foreach ( var dxfEntitiy in dxfEntities_.Entities ) {
                
                DxfEntityTreeNode dxfEntitiyTreeNode = DxfEntityTreeNode.TryFrom( dxfEntitiy, null ) ;
                if ( dxfEntitiyTreeNode == null )
                    continue ;
                    
                this.Nodes.Add( dxfEntitiyTreeNode ) ;
            }
        }
    }
}
